<template>
	<div class="home_wraper">
		<div class="home_content" id="homeContent">
			<MainContent v-if="curSelectedIndex == 0"></MainContent>
			<MyCollect class="" v-if="curSelectedIndex == 1"></MyCollect>
			<Me v-if="curSelectedIndex == 2"></Me>
		</div>
		<Tabbar :items = "tabbarItems" @itemClick="barClick" ref="tabbarData"></Tabbar>
	</div>
</template>

<script>
	import Tabbar from './pages/Tabbar.vue'
	import MainContent from './MainContent.vue'
	import Me from './Me/Me.vue'
	import MyCollect from './Me/MyCollect.vue'
	
	export default {
		metaInfo: {
			title: '火漫画',
			meta: [{
				name: 'Keywords',
				content: '火漫画画网首页,火漫画画网,火漫画,漫画列表,免费漫画,在线漫画,漫画大全,动漫之家,漫画网,无翻页漫画,少年漫画,热血漫画,少女漫画,搞笑漫画,古风漫画,优质漫画,H漫,摸鱼,漫画教程'
			}, {
				name: 'Description',
				content: '火漫画画网站的首页,漫画资源丰富,交互体验俱佳,看漫画一键滑到低,无需翻页,少年少女漫画为广大青年提供优质健康的漫画内容'
			}]
		},
	  components: {
		  Tabbar,
		  MainContent,
		  Me,
		  MyCollect
	  },
	  data() {
	  	return {
			curSelectedIndex:0,
	  		tabbarItems: [{"title":"首页","iconN":require('../resources/images/tabbar/home_tabbar.png'),"iconS":require('../resources/images/tabbar/home_tabbar_selected.png')},
			{"title":"收藏","iconN":require('../resources/images/tabbar/love_tabbar.png'),"iconS":require('../resources/images/tabbar/love_tabbar_selected.png')},
			{"title":"我的","iconN":require('../resources/images/tabbar/me_tabbar.png'),"iconS":require('../resources/images/tabbar/me_tabbar_selected.png')}],
	  	}
	  },
	  mounted() {
		  //从tabbar里面获取参数的值
		  let curIndex = this.$refs.tabbarData.selectedIndex
		  this.curSelectedIndex = curIndex
	  	// let type = this.$route.query.type;
	  	console.log('curIndex:' + curIndex);
		//首页不需要缩放功能
		var viewports=	document.getElementsByName("viewport");
		console.log("viewports="+viewports);
		for (var i = 0; i < viewports.length; i++) {
			viewports[i].content ="width=device-width,initial-scale=1.0, minimum-scale=1.0,maximum-scale=1.0";
		}
	  },
	  activated(){
		  if (!this.$route.meta.isUseCache) {
          // 需要重新刷新数据
		  console.log("首页需要重新刷新数据")
        }
		//beforeRouteEnter,beforeRouteLeave,在这两个方法处拦截，决定是否需要刷新，详情见WorkDetail.vue页面
        this.$route.meta.isUseCache = false;
	  },
	  methods:{
	  	barClick:function (index) {
			this.curSelectedIndex = index
	  		console.log("home点击："+index)
	  	}
	  }
	}
</script>

<style scoped>
	.home_wraper {
		width: 100%;
		height: 100%;
		overflow: hidden;
		display: flex;
		flex-direction: column;
		flex: 1;
	}
	
	.home_content {
		overflow: auto;
		flex: 1;
	}
</style>
